<template>
  <div class="my-love">
    <header>
      <i @click="back"></i>
      <div class="title">我的收藏</div>
    </header>

    <main>
      <div class="num">{{num}}篇文章</div>

      <div class="content">
        <ul>
          <li v-for="d in dataArr" :key="d.id" @click="goToHomeItem(d.id)">
            <van-image fit="cover" width="100" height="100" :src="d.src" alt />
          </li>
        </ul>
      </div>
    </main>
  </div>
</template>

<script>
export default {
  name: "MyCollection",
  data() {
    return {
      dataArr: []
    };
  },
  mounted() {
    this.dataArr = this.$store.state.myCollection;
  },
  methods: {
    back() {
      this.$router.back();
    },

    goToHomeItem(id) {
      this.$router.push({
        name: "item",
        params: {
          id
        }
      });
    }
  },
  computed: {
    num() {
      return this.dataArr.length;
    }
  }
};
</script>

<style lang="scss" scoped>
.my-love {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: auto;
  z-index: 100;
  background-color: #fff;

  header {
    width: 58vw;
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    i {
      width: 15px;
      height: 15px;
      margin: 0 10px;
      display: block;
      background-repeat: no-repeat;
      background-position: center center;
      background-size: contain;
      background-image: url("~@/assets/images/user/icon_back.png");
    }

    .title {
      font-size: 18px;
      font-weight: 700;
    }
  }

  main {
    .num {
      font-size: 16px;
      margin: 10px;
    }
    .content {
      ul {
        width: 94vw;
        margin: 0 auto;
        display: flex;
        flex-flow: row wrap;
        justify-content: space-between;
        align-items: center;
        li {
          width: 30%;
          padding: 5px;
          img {
            width: 100px;
            height: 100px;
          }
        }
      }
    }
  }
}
</style>